#include "StdAfx.h"
#include "MultiMapManager.h"


CMultiMapManager::CMultiMapManager(void)
{
}

CMultiMapManager::~CMultiMapManager(void)
{
}

void CMultiMapManager::RegisterWnd(HWND hWnd, DWORD nWndIndex, CMultiEMap* pWnd)
{
	WndInfo info;
	info.nWndIndex = nWndIndex;
	info.pWnd = pWnd;

	m_multiMap[hWnd] = info; 
}

void CMultiMapManager::SetActiveWnd(WndInfo* pWndInfo)
{
	pWndInfo->pWnd->SetActiveDisplayWnd(pWndInfo->nWndIndex);
	pWndInfo->pWnd->m_pEMapSetIfo[pWndInfo->nWndIndex].pEMap->LButtonDown();
}

void CMultiMapManager::RestoreWndStyle(WndInfo* pWndInfo)
{
	pWndInfo->pWnd->RestoreStyle();
}

WndInfo* CMultiMapManager::GetWnd(HWND hWnd)
{
	CMultiMap::iterator Iter = m_multiMap.find(hWnd);

	if(Iter == m_multiMap.end())
		return NULL;
	else
		return &(Iter->second);
}

void CMultiMapManager::SwapWndIndex(int nSrcIndex, int nTargetIndex)
{
	for (CMultiMap::iterator Iter = m_multiMap.begin(); Iter != m_multiMap.end(); ++Iter)
	{
		if(Iter->second.nWndIndex == nSrcIndex)
		{
			Iter->second.nWndIndex = nTargetIndex;
			continue;
		}
		if(Iter->second.nWndIndex == nTargetIndex)
		{
			Iter->second.nWndIndex = nSrcIndex;
			continue;
		}
	}
}
